/* Program for deploying a website to the cloud.  Run with:
 *
 *		deploy path
 *
 *		e.g.
 *		deploy mysite/
 */
package main

import (
	"log"
	"os"
	"http"
	"flag"
)

type visitor struct {
}

func uploadFile(path string) {

	log.Println("uploading file: ", path)

	reader, err := os.Open(path)

	if err != nil {
		log.Fatal("failed to open file: ", path)
	}

	res, err := http.Post("http://root.cloud9lib.net/fs/" + path, "text/plain", reader)

	if err != nil {
		log.Fatal("failed to upload: ", path)
	}

	log.Print(res.Status)
}

func main () {

	flag.Parse()

	for _, arg := range flag.Args() {
		uploadFile(arg)
	}

	log.Println("done.")
}
